﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QstkCore;
using QstkCore.Util;

namespace Tests
{
    [TestClass]
    public class MathUtilTests
    {
        [TestMethod]
        public void TestCumProdBasicList()
        {
            var list = new List<double> {1, 2, 3};

            var result = list.CumulativeProduct();

            var expected = new List<double> {1, 2, 6};

            CollectionAssert.AreEqual(result.ToList(), expected);
        }

        [TestMethod]
        public void TestCumProdMuliDimAxis0()
        {
            double[,] list = {{1, 2, 3}, {4, 5, 6}};

            var result = list.CumulativeProduct();

            double[,] expected = {{ 1, 2, 3 }, { 4, 10, 18 }};

            CollectionAssert.AreEqual(result, expected);
        }

        [TestMethod]
        public void TestCumProdMuliDimAxis1()
        {
            double[,] list = {{ 1, 2, 3 }, { 4, 5, 6 }};

            var result = list.CumulativeProduct(axis: 1);

            double[,] expected = {{ 1, 2, 6 }, { 4, 20, 120 }};

            CollectionAssert.AreEqual(result, expected);
        } 
    }
}
